Skip to content

refactor: Move tab styles from the tab link to the tab container - #5248

Draft
vvaliyev wants to merge 1 commit into
mainfrom
style-v2-tabs-refactor
Draft

vvaliyev wants to merge 1 commit into
mainfrom
style-v2-tabs-refactor

Conversation

@vvaliyev

@vvaliyev vvaliyev commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Description

Moves the tab's painted styles (background, border, border radius, block padding, colour and font per state) from the tab link to the tab container, so one element paints the tab and the upcoming internal style API can target it. The link, the action and the dismiss button cancel the moved block padding with negative margins, so the link keeps its size, focus ring and click area, and the action and dismiss button keep their own text style.

style.tab.paddingBlock moves to two custom properties, styleTabsPaddingBlockStart and styleTabsPaddingBlockEnd, so the moved padding and the negative margins follow it. Adding them changes the hash suffix of all custom properties, which updates the style snapshots of other components.

Visible changes:

  • Default rendering: none.
  • Without @cloudscape-design/global-styles, button tab labels inherit the font family instead of using the browser default.
  • style.tab (core system only): backgroundColor, borderColor and borderRadius paint the whole tab, including its inline padding, the action and the dismiss button, so adjacent tabs touch. The separator stays visible over a coloured tab, inside its end border. Hover colours still apply only while the pointer is over the link.
  • style.tab.borderWidth sets the tab's outer border. The label and the tab size stay the same; with a width other than 1px the underline and the separators move inside by the difference.
  • style.tab.paddingBlock: no change. The link, the action and the dismiss button follow the set padding, so the label, the tab size, the focus ring and the click area are as before.

Related links, issue #, if available: n/a

How has this been tested?

Unit tests, and a pixel comparison of the Tabs dev pages against main at rest, hovered, focused and active: classic and One Theme in both densities; visual refresh in both densities, light and dark, LTR and RTL. The label, link, focus ring and tab boxes with style.tab.paddingBlock of 0px, 4px and 4px 8px match main in classic and visual refresh.

Review checklist

The following items are to be evaluated by the author(s) and the reviewer(s).

Correctness

  • Changes include appropriate documentation updates.
  • Changes are backward-compatible if not indicated, see CONTRIBUTING.md.
  • Changes do not include unsupported browser features, see CONTRIBUTING.md.
  • Changes were manually tested for accessibility, see accessibility guidelines.

Security

Testing

  • Changes are covered with new/existing unit tests?
  • Changes are covered with new/existing integration tests?

By submitting this pull request, I confirm that you can use, modify, copy, and redistribute this contribution, under the terms of your choice.

@codecov

codecov Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 97.82%. Comparing base (ab62434) to head (1a13586).
⚠️ Report is 5 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #5248      +/-   ##
==========================================
- Coverage   97.82%   97.82%   -0.01%     
==========================================
  Files        1006     1006              
  Lines       32621    32648      +27     
  Branches    12117    12133      +16     
==========================================
+ Hits        31913    31939      +26     
- Misses        666      703      +37     
+ Partials       42        6      -36     

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The tab styling clips keyboard focus rings when custom padding is zero and leaves separators visible over filled tab backgrounds.

2 open issues
What changed in this PR

Moves tab painting from the link to the container, preparing Tabs for the upcoming internal style API while aiming to preserve default rendering and interaction geometry.

Changes:

  • Moves backgrounds, borders, block padding, and state typography to the container; keeps inline padding on the trigger.
  • Adjusts trigger, action, and dismiss styles to compensate for the moved styles.
  • Updates style tests and adds disabled-tab examples.
File Description
src/​tabs/​tab-header-bar.tsx Applies styles to the container and trigger separately.
src/​tabs/​tab-header-bar.scss Moves painting and state styles; adjusts child spacing and inheritance.
src/​tabs/​styles.tsx Adds a trigger-specific inline-padding helper.
src/​tabs/​__tests__/​tabs.test.tsx Tests style placement on rendered elements.
src/​tabs/​__tests__/​styles.test.tsx Covers the new helper and non-core behavior.
src/​tabs/​__tests__/​__snapshots__/​styles.test.tsx.snap Updates snapshots for the split style mapping.
pages/​tabs/​actions.page.tsx Adds disabled tabs with text actions and dismiss buttons.

Review effort: Balanced

line-height: awsui.$line-height-tabs;
font-weight: awsui.$font-weight-tabs;
color: var(#{custom-props.$styleColorDefault}, awsui.$color-text-interactive-default);
background-color: var(#{custom-props.$styleBackgroundDefault}, transparent);
Comment thread src/tabs/tab-header-bar.scss Resolved

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🟡 Changes recommended

The padding logic misaligns action/dismiss controls with font-relative padding and differing tab/body font sizes, and invalidates padding and cancellation margins for variable-backed two-value padding.

3 open issues
1 resolved since last review

Review effort: Balanced

Comment thread src/tabs/styles.tsx
if (current) {
parts.push(current);
}
return [parts[0], parts[1] ?? parts[0]];
margin-block-start: calc(-1 * #{$tab-padding-block-start});
margin-block-end: calc(-1 * #{$tab-padding-block-end});
// The colour and font of the tab apply to its label only.
@include styles.default-text-style;

This branch was successfully deployed

3 active deployments
dev-pages-react18 — 1a13586a Deployed Nov 4, 2026 by vvaliyev via deploy (React 18) / deploy #3174
dev-pages-react16 — 1a13586a Deployed Nov 4, 2026 by vvaliyev via deploy (React 16) / deploy #3174
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants